<?xml version="1.0" encoding="UTF-8" ?>

<!--
    Document   : prepareDoc.xsl
    Created on : 24. September 2007, 13:45
    Author     : jtrapp
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
                xmlns:kml="http://earth.google.com/kml/2.2"
                >
    <xsl:output method="xml"/>
    <xsl:param name="language"/>
    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/">
        <project basedir=".">
            <xsl:attribute name="name">splitKML<xsl:value-of select="$language"/></xsl:attribute>
            <xsl:attribute name="default">splitKML<xsl:value-of select="$language"/></xsl:attribute>
            <xsl:apply-templates select="kml:kml"/> 
        </project>
    </xsl:template>
    
    <xsl:template match="kml:Document">
        <xsl:apply-templates select="kml:Folder"/>                    
    </xsl:template>
    
    <xsl:template match="kml:Folder">
        <target>
            <xsl:attribute name="name">splitKML<xsl:value-of select="$language"/></xsl:attribute>
            <xsl:apply-templates select="kml:Placemark"/>        
        </target>
    </xsl:template>   
    
    
    <xsl:template match="kml:Placemark">
        <xslt style="xsl/prepareDoc.xsl">
            <xsl:attribute name="destdir">build/generdata/<xsl:value-of select="$language"/></xsl:attribute>
            <xsl:attribute name="basedir">build/generdata/<xsl:value-of select="$language"/></xsl:attribute>

            <xsl:attribute name="in">data/yab_<xsl:value-of select="$language"/>.kml</xsl:attribute>
            <xsl:attribute name="out">build/generdata/<xsl:value-of select="$language"/>/yab<xsl:value-of select="position()"/>.kml</xsl:attribute>
            <xsl:attribute name="extension">.kml</xsl:attribute>
            <param name="placemark">
                <xsl:attribute name="expression"><xsl:value-of select="position()"/></xsl:attribute>
            </param>
            <!--xmlcatalog id="ebscatalog">
                <catalogpath >
                    <fileset 
                    dir="${dist.dir}/xml"
                    includes="**/ebscatalog.xml"/>
                </catalogpath>
            </xmlcatalog--> 
        </xslt>
    </xsl:template>
    
    
    
</xsl:stylesheet>
